package forum.client;

/**
 * This singleton class holds all the session data, 
 * current user for example.
 */
public class SessionData {
	private static SessionData instance = null;
	private String currentUser;
	private UserPermissions permissions;
	private String currentSearch;	//The post id string to search for display. 
	private int pagingRange;
	private int postsCount;
	
	private SessionData() {
		this.currentUser = "";
		this.permissions = UserPermissions.GUEST;
		this.currentSearch = null;
		this.pagingRange = -1;	//-1 is all of the posts. 
	}
	
	/**
	 * the getInstance method of the singleton.
	 * @return the instance of the singleton.
	 */
	public static SessionData getInstance() {
		if (instance == null) {
			instance =  new SessionData();
		}
		return instance;
	}
	
	/**
	 * @return the currentUser
	 */
	public String getCurrentUser() {
		return this.currentUser;
	}
	
	/**
	 * @param currentUser the currentUser to set
	 */
	public void setCurrentUser(String currentUser) {
		this.currentUser = currentUser;
	}
	
	/**
	 * @return the permissions
	 */
	public UserPermissions getPermissions() {
		return this.permissions;
	}
	
	/**
	 * @param permissions the permissions to set
	 */
	public void setPermissions(UserPermissions permissions) {
		this.permissions = permissions;
	}

	/**
	 * @return the currentSearch
	 */
	public String getCurrentSearch() {
		return currentSearch;
	}

	/**
	 * @param currentSearch the currentSearch to set
	 */
	public void setCurrentSearch(String currentSearch) {
		this.currentSearch = currentSearch;
	}
	/**
	 * @return the pagingRange
	 */
	public int getPagingRange() {
		return pagingRange;
	}

	/**
	 * @param pagingRange the pagingRange to set
	 */
	public void setPagingRange(int pagingRange) {
		this.pagingRange = pagingRange;
	}

	/**
	 * @return the postsCount
	 */
	public int getPostsCount() {
		return postsCount;
	}

	/**
	 * @param postsCount the postsCount to set
	 */
	public void setPostsCount(int postsCount) {
		this.postsCount = postsCount;
	}
	
}
